package com.prs.crm.dao.project.impl;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.project.TaskTransmitDao;
import com.prs.crm.domain.project.Task;
import com.prs.crm.domain.project.TaskTransmit;

public class TaskTransmitDaoImpl extends BaseDaoImpl<TaskTransmit> implements TaskTransmitDao{

	public TaskTransmit findTransmit(final Task task,final Integer status)
	{
		return (TaskTransmit)this.getHibernateTemplate().execute(
			      new HibernateCallback() {   
						public Object doInHibernate(Session session) throws HibernateException {
				        	Criteria criteria = session.createCriteria(TaskTransmit.class);
				        	criteria.add(Restrictions.eq("task", task))
				        				.add(Restrictions.eq("status", status));
				        	
				        	return criteria.uniqueResult();
				        }   
				 } );
	}
}
